version: "3.5"

services:
  server:
    build:
      dockerfile: ./Dockerfile
      context: ./web
    depends_on:
      - db
      - redis
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
      - NEXTAUTH_SECRET=mysecret
      - SALT=mysalt
      - NEXTAUTH_URL=http://localhost:3000
      - TELEMETRY_ENABLED=${TELEMETRY_ENABLED:-true}
      - NEXT_PUBLIC_SIGN_UP_DISABLED=${NEXT_PUBLIC_SIGN_UP_DISABLED:-false}
      - LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES=${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-false}
      - REDIS_URL=${REDIS_URL:-redis}
      - REDIS_PORT=${REDIS_PORT:-6379}
      - REDIS_AUTH=${REDIS_AUTH:-myredissecret}
    restart: always

  worker:
    build:
      dockerfile: ./Dockerfile
      context: ./worker
    depends_on:
      - db
      - redis
      - server
    ports:
      - "3030:3030"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
      - NEXTAUTH_SECRET=mysecret
      - TELEMETRY_ENABLED=${TELEMETRY_ENABLED:-true}
      - LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES=${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-false}
      - PORT=${PORT:-3030}
      - REDIS_URL=${REDIS_URL:-redis}
      - REDIS_PORT=${REDIS_PORT:-6379}
      - REDIS_AUTH=${REDIS_AUTH:-myredissecret}
    restart: always

  redis:
    image: redis
    command: >
      --requirepass ${REDIS_AUTH:-myredissecret}
    restart: always
    ports:
      - 6379:6379

  db:
    image: postgres
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
    ports:
      - 5432:5432
    volumes:
      - database_data:/var/lib/postgresql/data

volumes:
  database_data:
    driver: local
